﻿@model DLMemberPointMS.Entity.ViewModel.MemCardSEditViewModel
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>会员换卡</title>
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <style>
        #top .layui-form-label {
            text-align: left;
            padding: 5px 10px;
            margin-top: 5px;
        }
    </style>
</head>
<body>
    <div style="margin:5px">
        <fieldset class="layui-elem-field">
            <legend>会员卡基本信息</legend>
            <div class="layui-field-box" id="top" style="border:5px">
                <div class="layui-input-inline">
                    <label class="layui-form-label">会员姓名：</label>
                    <div class="layui-input-block">
                        <label id="outid" class="layui-form-label"> @Html.DisplayFor(model => model.MC_Name, new { htmlAttributes = new {  @class = "layui-input layui-disabled" } })</label>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">会员卡号：</label>
                    <div class="layui-input-block">
                        <label id="MC_CardID" class="layui-form-label"> @Html.DisplayFor(model => model.MC_CardID, new { htmlAttributes = new { @class = "layui-input layui-disabled" } })</label>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">会员等级：</label>
                    <div class="layui-input-block">
                        <label class="layui-form-label"> @Html.DisplayFor(model => model.CL_LevelName, new { htmlAttributes = new { @class = "layui-input layui-disabled" } })</label>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">登记日期：</label>
                    <div class="layui-input-block">
                        <label class="layui-form-label" style="width:160px"> @Html.DisplayFor(model => model.MC_CreateTime, new { htmlAttributes = new { @class = "layui-input layui-disabled" } })</label>

                    </div>
                </div>
            </div>
        </fieldset>
        <form class="layui-form">
            <fieldset class="layui-elem-field">
                <legend>换卡信息</legend>
                <div class="layui-field-box" id="form" style="border:5px">
                    <div class="layui-input-inline">
                        <label class="layui-form-label">原卡密码：</label>
                        <div class="layui-input-block">
                            <input type="text" id="MC_Old_CardPwd" value="" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">新卡号：</label>
                        <div class="layui-input-block">
                            <input type="text" id="MC_New_CardID" value="" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">新卡密码：</label>
                        <div class="layui-input-block">
                            <input type="text" id="MC_New_Password" value="" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">确认密码：</label>
                        <div class="layui-input-block">
                            <input type="text" id="MC_Password_confirm" value="" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <div class="layui-btn-container">
                            <label class="layui-form-label"></label>
                            <button type="button" class="layui-btn layui-btn-sm" id="submit" lay-submit lay-filter="submitform"><i class="layui-icon">&#xe654;确定</i></button>
                            <button type="button" class="layui-btn layui-btn-sm" id="close"><i class="layui-icon">关闭</i></button>
                        </div>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form,
                layer = layui.layer;

            form.on('submit(submitform)', function (data) {
                var index = parent.layer.getFrameIndex(window.name); //得到当前iframe层的索引
                var MC_CardID = $('#MC_CardID').text().trim();
                var MC_Old_CardPwd = $('#MC_Old_CardPwd').val();
                var MC_New_CardID = $('#MC_New_CardID').val();
                var MC_New_Password = $('#MC_New_Password').val();
                var MC_Password_confirm = $('#MC_Password_confirm').val();
                $.ajax({
                    url: '/Member/ChangeCardResult',
                    type: 'post',
                    data: { "MC_CardID": MC_CardID, "MC_Password": MC_Old_CardPwd, "MC_New_CardID": MC_New_CardID, "MC_New_Password": MC_New_Password, "MC_Password_confirm": MC_Password_confirm },
                    success: function (data) {
                        if (data.code == 0) {
                            parent.layer.msg(data.msg, { icon: 1 })
                            parent.layer.close(index); //再执行关闭
                        } else {
                            parent.layer.msg(data.msg, { icon: 2 })
                            parent.layer.close(index); //再执行关闭
                        }
                    },
                    error: function (data) {
                        parent.layer.msg(data.msg, { icon: 2 })
                        parent.layer.close(index); //再执行关闭
                    }
                })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
         $('#close').click(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })

        })
    </script>
</body>
</html>
